#include "chipio_def.h"
#include "bsp.h"
#include "stm32f1xx_hal.h"
void Key_Init(void){

}

int Key_GetNum(void)
{
    int keyNum = 0;
    if(GPIO_PIN_RESET == KEY1_STATE){
        HAL_Delay(20);  //按下消抖
        while(GPIO_PIN_RESET == KEY1_STATE);
        HAL_Delay(20);  //松手消抖
        keyNum = 1;
    }
    else if(GPIO_PIN_RESET == KEY2_STATE){
        HAL_Delay(20);
        while(GPIO_PIN_RESET == KEY2_STATE);
        HAL_Delay(20);
        keyNum = 2;
    }
    return keyNum;
}

void TestKey(){
  while(1){
    uint8_t key = Key_GetNum();
    if(key == KEY0_PRES){
        LED1_TOGGLE;
    }
    else if(key == KEY1_PRES){
        LED2_TOGGLE;
    }
    HAL_Delay(20);
  }
}
